package com.project.controller;

import com.common.annotation.Log;
import com.common.core.controller.BaseController;
import com.common.core.domain.AjaxResult;
import com.common.core.page.PageDomain;
import com.common.core.page.TableDataInfo;
import com.common.enums.BusinessType;
import com.github.pagehelper.PageHelper;
import com.project.domain.bo.BizUnitAptitudeBo;
import com.project.domain.entity.BizUnitAptitude;
import com.project.service.IUnitAptitudeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 合同供方单位
 *
 * @author baige
 * @date 2025-02-08
 */
@Api(tags = "合同供方单位")
@RestController
@RequestMapping("/project/htgfdw")
public class UnitAptitudeController extends BaseController {

    @Autowired
    private IUnitAptitudeService unitAptitudeService;

    /**
     * 新增供方单位
     */
//    @PreAuthorize("@ss.hasPermi('project:htgfdw:add')")
    @Log(title = "合同供方单位", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增")
    @PostMapping
    public AjaxResult add(@RequestBody BizUnitAptitude unitAptitude) {
        return toAjax(unitAptitudeService.addUnitAptitude(unitAptitude));
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除")
//    @PreAuthorize("@ss.hasPermi('project:htgfdw:remove')")
    @Log(title = "合同供方单位", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(unitAptitudeService.delUnitAptitude(ids));
    }

    /**
     * 修改供方单位
     */
    @ApiOperation(value = "修改")
//    @PreAuthorize("@ss.hasPermi('project:htgfdw:edit')")
    @Log(title = "合同供方单位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizUnitAptitude unitAptitude) {
        return toAjax(unitAptitudeService.updateUnitAptitude(unitAptitude));
    }

    /**
     * 查询列表
     */
    @ApiOperation(value = "查询列表")
//    @PreAuthorize("@ss.hasPermi('project:htgfdw:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody BizUnitAptitudeBo bo,@RequestBody PageDomain page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<BizUnitAptitude> list = unitAptitudeService.getUnitAptitudeList(bo);
        return getDataTable(list);
    }

    /**
     * 数量统计
     */
    @ApiOperation(value = "数量统计")
    @PostMapping(value = "/list-statistics")
    public AjaxResult listStatistics(@RequestBody BizUnitAptitudeBo bo) {
        return success(unitAptitudeService.listStatistics(bo));
    }

    /**
     * 获取详情
     */
    @ApiOperation(value = "详情")
//    @PreAuthorize("@ss.hasPermi('project:htgfdw:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(unitAptitudeService.getUnitAptitudeIndex(id));
    }


}
